import { Controller, Get, Post, Body, Optional, Injectable, Inject, Query, Req } from '@nestjs/common'
import { Request } from 'express'
import { LoginDTO } from './user.dto'
import { UserService } from './user.service'

@Controller('login')
@Injectable()
export class UserController {
    // 依赖注入 service
    constructor(@Optional() @Inject(UserService) private readonly userService: UserService) {}

    @Post()
    createUser(@Body() loginDTO: LoginDTO, @Req() request: Request) {
        console.log(request.cookies)
        console.log(loginDTO)
        return this.userService.findAll()
    }

    @Get()
    findOne(@Query() query: LoginDTO, @Req() request: Request) {
        console.log(request.cookies)
        console.log('-------- 入参 -----------')
        console.log(query)
        return this.userService.findOne(2)
    }
}
